package com.lsh.payment.core.handler;

import com.lsh.payment.api.model.basevo.ExceptionStatus;
import com.lsh.payment.core.exception.BusinessException;
import com.lsh.payment.core.handler.impl.RefundOrderStatusServiceHandler;
import com.lsh.payment.core.model.payenum.RefundStatus;
import com.lsh.payment.core.service.refund.IRefundOrderStatusService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Project Name: lsh-payment
 *
 * @author peter
 * @date 18/6/4
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
public abstract class AbstractRefundChannelHandler implements IRefundChannelHandler {

    @Autowired
    private RefundOrderStatusServiceHandler refundOrderStatusServiceHandler;
    /**
     * 获取退款单状态流转处理服务
     * @param refundStatus   退款单状态
     * @return               退款单状态流转处理服务
     */
    protected IRefundOrderStatusService getRefundOrderStatusService(RefundStatus refundStatus){
        IRefundOrderStatusService refundOrderStatusService = refundOrderStatusServiceHandler.refundOrderStatusService(refundStatus);

        if (refundOrderStatusService == null) {

            throw new BusinessException(ExceptionStatus.E2001006.getCode(), "暂不支持该渠道的退款");
        }

        return refundOrderStatusService;
    }
}
